
#include <stdio.h>

int main()
{
    FILE *pf =fopen("xx.txt","w+");
    char buf[1024] = "123456";
    fwrite(buf,1,9,pf);
    rewind(pf);

    char rbuf[1024];
    int n;
//    n = fread(rbuf,1024,1,pf);
//    printf("n = %d\n",n);
//    n = fread(rbuf,1024,1,pf);
//    printf("n = %d\n",n);
//    n = fread(rbuf,1024,1,pf);
//    printf("n = %d\n",n);
//    n = fread(rbuf,1024,1,pf);
//    printf("n = %d\n",n);
//    n = fread(rbuf,1,1024,pf);
//    printf("n = %d\n",n);
//    n = fread(rbuf,1,1024,pf);
//    printf("n = %d\n",n);
//    n = fread(rbuf,1,1024,pf);
//    printf("n = %d\n",n);
//    n = fread(rbuf,1,1024,pf);
//    printf("n = %d\n",n);
    n = fread(rbuf,1,4,pf);
    printf("n = %d\n",n);
    n = fread(rbuf,1,4,pf);
    printf("n = %d\n",n);
    n = fread(rbuf,1,4,pf);
    printf("n = %d\n",n);
    n = fread(rbuf,1,4,pf);
    printf("n = %d\n",n);
}

int main2()
{
    int arr[10] = {1,2,3,4,5,6,7,8,9,10};
    FILE *pf = fopen("xx.txt","w+");
    if(NULL == pf)
        exit(-1);
//    fwrite((void*)buf,1,8,pf);
    fwrite((void*)arr,4,10,pf);

    rewind(pf);
    char read[10];
    // 读到完整块的个数
    int n;
    while((n = fread((void*)arr,4,5,pf)) > 0)
    {
        for (int i = 0; i < n; i++)
            printf("%d\n",arr[i]);
    }
    fclose(pf);
//    printf("Hello World!\n");
    return 0;
}

int main1()
{
    char buf[1024] = "12345678";
    FILE *pf = fopen("oo.txt","w+");
    if(NULL == pf)
        exit(-1);
//    fwrite((void*)buf,1,8,pf);
    fwrite((void*)buf,8,1,pf);

    rewind(pf);
    char read[10];
    // 读到完整块的个数
    int n;
//    n = fread((void*)read,1,8,pf);
//    printf("n = %d\n",n);
//    n = fread((void*)read,1,8,pf);
//    printf("n = %d\n",n);
//    n = fread((void*)read,8,1,pf);
//    printf("n = %d\n",n);
//    n = fread((void*)read,8,1,pf);
//    printf("n = %d\n",n);

//    n = fread((void*)read,7,1,pf);
//    printf("n = %d\n",n);
//    n = fread((void*)read,7,1,pf);
//    printf("n = %d\n",n);

//    n = fread((void*)read,3,1,pf);
//    printf("n = %d\n",n);
//    n = fread((void*)read,3,1,pf);
//    printf("n = %d\n",n);

//    n = fread((void*)read,1,3,pf);
//    printf("n = %d\n",n);
//    n = fread((void*)read,1,3,pf);
//    printf("n = %d\n",n);
//    n = fread((void*)read,1,3,pf);
//    printf("n = %d\n",n);

    while((n = fread((void*)read,1,3,pf)) > 0)
    {
        for (int i = 0; i < n; i++)
            printf("%c",read[i]);
    }
    fclose(pf);
//    printf("Hello World!\n");
    return 0;
}
